package Exercises;/*
 *
 * @author 陈粒
 * @version 创建时间：2021/7/2 16:08
 */
/**
 * 阶乘
 */

import java.util.*;

public class Factorial {
    public static void main(String[] args) {
        System.out.println("请输入一个正整数：");
        int Num = new Scanner(System.in).nextInt();
        int Result = 1;
        if (Num < 0) {
            System.out.println("输入的数据小于0，请重新输入");
            return;
        } else if (Num == 0) {
            System.out.println("0的阶乘为1");
        } else if (Num == 1) {
            System.out.println("1的阶乘为1");
        } else if (Num > 0) {
            for (int i = Num; i > 1; i--) {
                Result = Result * i;
            }
            System.out.println(Num + "的阶乘为：" + Result);
        }
    }
}